package com.lkd.controller;

import com.lkd.dto.VmTypeDto;
import com.lkd.entity.VmType;
import com.lkd.result.PageBean;
import com.lkd.result.Result;
import com.lkd.service.VmTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
public class VmTypeController {

    @Autowired
    private VmTypeService vmTypeService;

    //分页查询
    @GetMapping("/api/vm-service/vmType/search")
    public Result findByPage(VmTypeDto dto){
        PageBean<VmType> pageBean = vmTypeService.findByPage(dto);
        return Result.success(pageBean);
    }

    //新增
    @PostMapping("/api/vm-service/vmType")
    public Result save(@RequestBody VmType vmType){
        Boolean result = vmTypeService.save(vmType);
        return Result.success(result);
    }


    //修改
    @PutMapping("/api/vm-service/vmType")
    public Result update(@RequestBody VmType vmType){
        Boolean result = vmTypeService.update(vmType);
        return Result.success(result);
    }

    //主键删除
    @DeleteMapping("/api/vm-service/vmType/{typeId}")
    public Result deleteById(@PathVariable("typeId") Integer typeId){
        Boolean result = vmTypeService.deleteById(typeId);
        return Result.success(result);
    }

    //主键查询
    @GetMapping("/api/vm-service/vmType/{typeId}")
    public Result findById(@PathVariable("typeId") Integer typeId){
        VmType vmType = vmTypeService.findById(typeId);
        return Result.success(vmType);
    }
}
